Declare Function GetSystemMenu Lib "User" (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer
Declare Function AppendMenu Lib "User" (ByVal hMenu As Integer, ByVal wFlags As Integer, ByVal wIDNewItem As Integer, ByVal lpNewItem As Any) As Integer
Declare Function InvokeWindowProc Lib "msghook.vbx" (ByVal hWnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Long
' Windows constants
Const WM_SYSCOMMAND = &H112
Const MF_STRING = &H0
Const MF_SEPARATOR = &H800
' ID for new About command (must be < &HF000)
Const IDM_ABOUT = 1
Sub Form_Load ()
Dim i As Integer
Dim hMenu As Integer
' Add "About..." command to system menu
hMenu = GetSystemMenu(Me.hWnd, False)
i = AppendMenu(hMenu, MF_SEPARATOR, 0, 0&)
i = AppendMenu(hMenu, MF_STRING, IDM_ABOUT, "&About...")
' Setup MsgHook
MsgHook.HwndHook = Me.hWnd
MsgHook.Message(WM_SYSCOMMAND) = True
End Sub
Sub MsgHook_Message (msg As Integer, wParam As Integer, lParam As Long, result As Long)
' Look for WM_SYSCOMMAND message with About command
If msg = WM_SYSCOMMAND Then
Select Case wParam
Case IDM_ABOUT
frmAbout.Show 1
result = 0
Exit Sub
End Select
End If
' Pass along to default handler if message not processed
result = InvokeWindowProc(MsgHook.HwndHook, msg, wParam, lParam)